package com.leetcode.根据数据结构分类.数组;

import java.util.HashSet;

/**
 * @author: ZhouBert
 * @date: 2020/12/7
 * @description:	两个数组的交集
 * https://leetcode-cn.com/problems/intersection-of-two-arrays/
 */
public class A_349_两个数组的交集 {

	public int[] intersection(int[] nums1, int[] nums2) {
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < nums1.length; i++) {
			set.add(nums1[i]);
		}

		HashSet<Integer> res = new HashSet<>();
		for (int i = 0; i < nums2.length; i++) {
			if (set.contains(nums2[i])){
				res.add(nums2[i]);
			}
		}
		int[] resArr = new int[res.size()];
		int index=0;
		for (Integer item:
			 res) {
			resArr[index++]=item;
		}

		return resArr;
	}

	public static void main(String[] args) {
		Float f=10.6f;
		System.out.println(f.hashCode());
		int hash = Float.floatToIntBits(f);
		System.out.println("hash = " + hash);


		//测试 hash value 超过 int.max 时会怎么样
		int testHashValue= Integer.MAX_VALUE+1;
		System.out.println("Int Max = " +Integer.MAX_VALUE);
		//符号位 变化了
		System.out.println("testHashValue = " + testHashValue);

		int a1 = 5;
		int a2 = 7;
		int after = a1 & a2;
		System.out.println("after = " + after);
	}


}
